%本程序的作用是绘制不同算法对异常点识别的效果，其中算法识别结果都在各自对应的mat文件中

clc
clear
currentDir = pwd; % 获取当前目录路径
parentDir = fileparts(currentDir); % 获取当前目录的上一级目录路径
% grandParentDir = fileparts(parentDir); % 获取当前目录的上两级目录路径
% greatGrandParentDir = fileparts(grandParentDir); % 获取当前目录的上三级目录路径

%指定需要查找的文件夹
subdir = 'DATA';
%指定需要查找的文件名
filename1 = 'my.mat';
filename2 = 'fhx.mat';
filename3 = 'lhm.mat';
filename4 = 'zlx.mat';
filename5 = 'LL.mat';
%构造需要查找的文件的完整路径
full_path1 = fullfile(parentDir, subdir, filename1);
load( full_path1)  
full_path2 = fullfile(parentDir, subdir, filename2);
load( full_path2)  
full_path3 = fullfile(parentDir, subdir, filename3);
load( full_path3) 
full_path4 = fullfile(parentDir, subdir, filename4);
load( full_path4) 
full_path5 = fullfile(parentDir, subdir, filename5);
load( full_path5) 

figure
x_range=[length(my.AIS.Lon),length(my.degrees_deleted),...
    length(fhx.degrees_deleted),length(lhm.degrees_deleted),...
    length(zlx.degrees_deleted),length(LL.degrees_deleted)];
x=ceil(max(x_range)/100)*100;

%绘制轨迹偏转角
t = tiledlayout(6,1);
ax11 = nexttile;
plot(ax11,my.degrees_AIS,'ko-');
title('原始');
xlim([1 x]);

ax12 = nexttile;
plot(ax12,fhx.degrees_deleted,'ko-');
title('F-算法');
xlim([1 x]);

ax13 = nexttile;
plot(ax13,lhm.degrees_deleted,'ko-');
title('L-算法');
xlim([1 x]);

ax14 = nexttile;
plot(ax14,LL.degrees_deleted,'ko-');
title(' LL-算法');
xlim([1 x]);

ax15 = nexttile;
plot(ax15,zlx.degrees_deleted,'ko-');
title('Z-算法');
xlim([1 x]);



ax16 = nexttile;
plot(ax16,my.degrees_deleted,'ko-');
title(' 本文算法');
xlim([1 x]);

% Link the axes
linkaxes([ax11,ax12,ax13,ax14,ax15,ax16],'x');

% Add shared title and axis labels
% title(t,'My Title')
xlabel(t,'轨迹点序号','fontsize',10)
ylabel(t,'偏转角/(°)','fontsize',10)

% Move plots closer together
xticklabels(ax11,{})
xticklabels(ax12,{})
xticklabels(ax13,{})
xticklabels(ax14,{})
xticklabels(ax15,{})

% 设置图块之间的间距为 'compact'
t.TileSpacing = 'compact'; % 可以设置为 'loose', 'compact', 'tight', 'none'


%绘制插值轨迹偏转角均值
x_range1=[length(my.degrees_spline),length(my.AIS.Lon),length(zlx.degrees_spline),length(LL.degrees_splined)];
x1=ceil(max(x_range1)/100)*100;

figure
t1 = tiledlayout(6,1);
ax21 = nexttile;
plot(ax21,LL.degrees_deleted,'ko-');
title('异常剔除轨迹(LL-算法)');
xlim([1 x1]);

ax22 = nexttile;
plot(ax22,LL.degrees_splined,'ko-');
title('修复轨迹(LL-算法)');
xlim([1 x1]);

ax23 = nexttile;
plot(ax23,zlx.degrees_deleted,'ko-');
title('异常剔除轨迹(Z-算法)');
xlim([1 x1]);

ax24 = nexttile;
plot(ax24,zlx.degrees_spline,'ko-');
title('修复轨迹(Z-算法)');
xlim([1 x1]);

ax25 = nexttile;
plot(ax25,my.degrees_deleted,'ko-');
title(' 异常剔除轨迹(本文算法)');
xlim([1 x1]);

ax26 = nexttile;
plot(ax26,my.degrees_spline,'ko-');
title(' 修复轨迹(本文算法)');
xlim([1 x1]);

% Link the axes
linkaxes([ax21,ax22,ax23,ax24,ax25,ax26],'x');

% Add shared title and axis labels
% title(t,'My Title')
xlabel(t1,'轨迹点序号','fontsize',10)
ylabel(t1,'偏转角/(°)','fontsize',10)

% Move plots closer together
xticklabels(ax21,{})
xticklabels(ax22,{})
xticklabels(ax23,{})
xticklabels(ax24,{})
xticklabels(ax25,{})

% 设置图块之间的间距为 'compact'
t1.TileSpacing = 'compact'; % 可以设置为 'loose', 'compact', 'tight', 'none'
